/***********************************************************
 * Product Name: ExcelQuicker
 * Copyright (c)2005, Eunge
 * Author: Eunge
 * Web Site: www.eudev.net
 * Mail/MSN: eudev.net@yeah.net
 * ********************************************************/
using System;

namespace ExcelQuicker.Framework
{
	/// <summary>
	/// Style Factory. Provides several usual style when we develop reports.
	/// </summary>
	public sealed class EQStyleFactory
	{
		private EQStyleFactory(){}

		#region Horizontal Alignment
		private static EQAlignment mAlignCenter = null;
		private static EQAlignment mAlignLeft = null;
		private static EQAlignment mAlignRight = null;

		/// <summary>
		/// Get center alignment of text
		/// </summary>
		public static EQAlignment AlignCenter
		{
			get
			{
				if(EQStyleFactory.mAlignCenter == null)
				{
					EQStyleFactory.mAlignCenter = new EQAlignment(Excel.XlHAlign.xlHAlignCenter);
				}
				return EQStyleFactory.mAlignCenter;
			}
		}

		/// <summary>
		/// Get left alignment of text
		/// </summary>
		public static EQAlignment AlignLeft
		{
			get
			{
				if(EQStyleFactory.mAlignLeft == null)
				{
					EQStyleFactory.mAlignLeft = new EQAlignment(Excel.XlHAlign.xlHAlignLeft);
				}
				return EQStyleFactory.mAlignLeft;
			}
		}

		/// <summary>
		/// Get right alignment of text
		/// </summary>
		public static EQAlignment AlignRight
		{
			get
			{
				if(EQStyleFactory.mAlignRight == null)
				{
					EQStyleFactory.mAlignRight = new EQAlignment(Excel.XlHAlign.xlHAlignRight);
				}
				return EQStyleFactory.mAlignRight;
			}
		}
		#endregion

		#region Border
		private static EQBorderStyle mBlackAndBlackBorder = null;
		private static EQBorderStyle mBlackAndGrayBorder  = null;
		private static EQBorderStyle mOuterBorder = null;
		/// <summary>
		/// Get style of black outer and inner thin border
		/// </summary>
		public static EQBorderStyle BlackAndBlackBorder
		{
			get
			{
				if(EQStyleFactory.mBlackAndBlackBorder == null)
				{
					EQStyleFactory.mBlackAndBlackBorder = new EQBorderStyle(1, 48);
					EQStyleFactory.mBlackAndBlackBorder.InnerBorderWeight = Excel.XlBorderWeight.xlThin;
					EQStyleFactory.mBlackAndBlackBorder.OuterBorderWeight = Excel.XlBorderWeight.xlThin;
				}
				return EQStyleFactory.mBlackAndBlackBorder;
			}
		}

		/// <summary>
		/// Get style of black outer and gray inner thin border
		/// </summary>
		public static EQBorderStyle BlackAndGrayBorder
		{
			get
			{
				if(EQStyleFactory.mBlackAndGrayBorder == null)
				{
					EQStyleFactory.mBlackAndGrayBorder = new EQBorderStyle(1, 1);
					EQStyleFactory.mBlackAndGrayBorder.InnerBorderWeight = Excel.XlBorderWeight.xlThin;
					EQStyleFactory.mBlackAndGrayBorder.OuterBorderWeight = Excel.XlBorderWeight.xlThin;
				}
				return EQStyleFactory.mBlackAndGrayBorder;
			}
		}

		/// <summary>
		/// Get the style of outer border with black color and thin weight
		/// </summary>
		public static EQBorderStyle OuterBorder
		{
			get
			{
				if(EQStyleFactory.mOuterBorder == null)
				{
					EQStyleFactory.mOuterBorder = new EQBorderStyle();
					EQStyleFactory.mOuterBorder.OuterColor = 1;
					EQStyleFactory.mOuterBorder.OuterBorderWeight = Excel.XlBorderWeight.xlThin;
				}
				return EQStyleFactory.mOuterBorder;
			}
		}
		#endregion

		#region Report Title Style
		private static EQRangeStyle mReportTitleStyle0 = null;
		private static EQRangeStyle mReportTitleStyle1 = null;
		private static EQRangeStyle mReportTitleStyle2 = null;
		private static EQRangeStyle mReportTitleStyle3 = null;
		/// <summary>
		/// Get the title style with size 20, black, bond and Arial font family. It's common for title of report.
		/// </summary>
		public static EQRangeStyle ReportTitleStyle0
		{
			get
			{
				if(EQStyleFactory.mReportTitleStyle0 == null)
				{
					EQStyleFactory.mReportTitleStyle0 = new EQRangeStyle();
					EQStyleFactory.mReportTitleStyle0.Bond = true;
					EQStyleFactory.mReportTitleStyle0.Size = 20;
					EQStyleFactory.mReportTitleStyle0.Family = "Arial";
					EQStyleFactory.mReportTitleStyle0.Color = 1;
				}
				return EQStyleFactory.mReportTitleStyle0;
			}
		}

		/// <summary>
		/// Get the title style with size 20, black, bond and Times New Roman  font family. It's common for title of report.
		/// </summary>
		public static EQRangeStyle ReportTitleStyle1
		{
			get
			{
				if(EQStyleFactory.mReportTitleStyle1 == null)
				{
					EQStyleFactory.mReportTitleStyle1 = new EQRangeStyle();
					EQStyleFactory.mReportTitleStyle1.Bond = true;
					EQStyleFactory.mReportTitleStyle1.Size = 20;
					EQStyleFactory.mReportTitleStyle1.Family = "Times New Roman";
					EQStyleFactory.mReportTitleStyle1.Color = 1;
				}
				return EQStyleFactory.mReportTitleStyle1;
			}
		}

		/// <summary>
		/// Get the title style with size 24, black, bond and Arial font family. It's common for title of report.
		/// </summary>
		public static EQRangeStyle ReportTitleStyle2
		{
			get
			{
				if(EQStyleFactory.mReportTitleStyle2 == null)
				{
					EQStyleFactory.mReportTitleStyle2 = new EQRangeStyle();
					EQStyleFactory.mReportTitleStyle2.Bond = true;
					EQStyleFactory.mReportTitleStyle2.Size = 24;
					EQStyleFactory.mReportTitleStyle2.Family = "Arial";
					EQStyleFactory.mReportTitleStyle2.Color = 1;
				}
				return EQStyleFactory.mReportTitleStyle2;
			}
		}

		/// <summary>
		/// Get the title style with size 24, black, bond and Times New Roman  font family. It's common for title of report.
		/// </summary>
		public static EQRangeStyle ReportTitleStyle3
		{
			get
			{
				if(EQStyleFactory.mReportTitleStyle3 == null)
				{
					EQStyleFactory.mReportTitleStyle3 = new EQRangeStyle();
					EQStyleFactory.mReportTitleStyle3.Bond = true;
					EQStyleFactory.mReportTitleStyle3.Size = 24;
					EQStyleFactory.mReportTitleStyle3.Family = "Times New Roman";
					EQStyleFactory.mReportTitleStyle3.Color = 1;
				}
				return EQStyleFactory.mReportTitleStyle3;
			}
		}
		#endregion

		#region Common Text Style
		private static EQRangeStyle mCommonTextStyle0 = null;
		private static EQRangeStyle mCommonTextStyle1 = null;
		private static EQRangeStyle mCommonTextStyle2 = null;
		private static EQRangeStyle mCommonTextStyle3 = null;

		/// <summary>
		/// Get the common text style with size 9, black color and Arial font family.
		/// </summary>
		public static EQRangeStyle CommonTextStyle0
		{
			get
			{
				if(EQStyleFactory.mCommonTextStyle0 == null)
				{
					EQStyleFactory.mCommonTextStyle0 = new EQRangeStyle();
					EQStyleFactory.mCommonTextStyle0.Size = 9;
					EQStyleFactory.mCommonTextStyle0.Family = "Arial";
					EQStyleFactory.mCommonTextStyle0.Color = 1;
				}

				return EQStyleFactory.mCommonTextStyle0;
			}
		}

		/// <summary>
		/// Get the common text style with size 10, black color and Arial font family.
		/// </summary>
		public static EQRangeStyle CommonTextStyle1
		{
			get
			{
				if(EQStyleFactory.mCommonTextStyle1 == null)
				{
					EQStyleFactory.mCommonTextStyle1 = new EQRangeStyle();
					EQStyleFactory.mCommonTextStyle1.Size = 10;
					EQStyleFactory.mCommonTextStyle1.Family = "Arial";
					EQStyleFactory.mCommonTextStyle1.Color = 1;
				}

				return EQStyleFactory.mCommonTextStyle1;
			}
		}
		/// <summary>
		/// Get the common text style with size 9, black color and Times New Roman font family.
		/// </summary>
		public static EQRangeStyle CommonTextStyle2
		{
			get
			{
				if(EQStyleFactory.mCommonTextStyle2 == null)
				{
					EQStyleFactory.mCommonTextStyle2 = new EQRangeStyle();
					EQStyleFactory.mCommonTextStyle2.Size = 9;
					EQStyleFactory.mCommonTextStyle2.Family = "Times New Roman";
					EQStyleFactory.mCommonTextStyle2.Color = 1;
				}

				return EQStyleFactory.mCommonTextStyle2;
			}
		}

		/// <summary>
		/// Get the common text style with size 10, black color and Times New Roman font family.
		/// </summary>
		public static EQRangeStyle CommonTextStyle3
		{
			get
			{
				if(EQStyleFactory.mCommonTextStyle3 == null)
				{
					EQStyleFactory.mCommonTextStyle3 = new EQRangeStyle();
					EQStyleFactory.mCommonTextStyle3.Size = 10;
					EQStyleFactory.mCommonTextStyle3.Family = "Times New Roman";
					EQStyleFactory.mCommonTextStyle3.Color = 1;
				}

				return EQStyleFactory.mCommonTextStyle3;
			}
		}
		#endregion

		#region Table Header Style
		/// <summary>
		/// Create a table header style from table items style.
		/// Generally, the header style differs from items style in bond font and gray background color.
		/// So, render the items style and return its relative header style.
		/// </summary>
		/// <param name="style"></param>
		/// <returns></returns>
		public static EQRangeStyle GreateTableHeaderStyle(EQRangeStyle style)
		{
			EQRangeStyle copy = style.Copy() as EQRangeStyle;
			copy.Bond = true;
			copy.BackColor = 15;
			return copy;
		}
		#endregion

		#region Table Alternative Item Style

		/// <summary>
		/// Create a alternativa item style from table item common style.
		/// Generally, the alternative item style differs from item style in background color.
		/// </summary>
		/// <param name="style"></param>
		/// <param name="backColor"></param>
		/// <returns></returns>
		public static EQRangeStyle CreateAlternativeItemStyle(EQRangeStyle style, int backColor)
		{
			EQRangeStyle copy = style.Copy() as EQRangeStyle;
			copy.BackColor = backColor;
			return copy;
		}
		#endregion

		#region Auto Fit Width
		private static EQMeasure mAutoFitWidth = null;
		/// <summary>
		/// Get auto fit width object. It's used to expand the width of cell/column by text in the cell of excel document.
		/// </summary>
		public static EQMeasure AutoFitWidth
		{
			get
			{
				if(EQStyleFactory.mAutoFitWidth == null)
				{
					EQStyleFactory.mAutoFitWidth = new EQMeasure();
					EQStyleFactory.mAutoFitWidth.AutoFitWidth = true;
				}
				return EQStyleFactory.mAutoFitWidth;
			}
		}
		#endregion

        #region BackColor Style

        private static EQRangeStyle mBackStyleGreen = null;
        private static EQRangeStyle mBackStyleYellow = null;
        private static EQRangeStyle mBackStyleBlue = null;

        /// <summary>
        /// Get the common back color style with Green backColor.
        /// </summary>
        public static EQRangeStyle BackStyleGreen
        {
            get
            {
                if (EQStyleFactory.mBackStyleGreen == null)
                {
                    EQStyleFactory.mBackStyleGreen = new EQRangeStyle();
                    EQStyleFactory.mBackStyleGreen.BackColor = (int)EQColor.Green;
                }
                return EQStyleFactory.mBackStyleGreen;
            }
        }

        /// <summary>
        /// Get the common back color style with Green backColor.
        /// </summary>
        public static EQRangeStyle BackStyleYellow
        {
            get
            {
                if (EQStyleFactory.mBackStyleYellow == null)
                {
                    EQStyleFactory.mBackStyleYellow = new EQRangeStyle();
                    EQStyleFactory.mBackStyleYellow.BackColor = (int)EQColor.Yellow;
                }
                return EQStyleFactory.mBackStyleYellow;
            }
        }

        /// <summary>
        /// Get the common back color style with Green backColor.
        /// </summary>
        public static EQRangeStyle BackStyleBlue
        {
            get
            {
                if (EQStyleFactory.mBackStyleBlue == null)
                {
                    EQStyleFactory.mBackStyleBlue = new EQRangeStyle();
                    EQStyleFactory.mBackStyleBlue.BackColor = (int)EQColor.Blue;
                }
                return EQStyleFactory.mBackStyleBlue;
            }
        }

        #endregion
    }
}
